wa = list(input())
ri = ""
ir = ""
iw = True
while True:
    try:
        ri = ""
        ir = ""
        if len(wa)==0:
            break
        for ia in range(len(wa)):
            if ia + 1 < len(wa):
                if wa[ia] + wa[ia+1] == "()" or wa[ia] + wa[ia+1] == "[]" or wa[ia] + wa[ia+1] == "{}" or wa[ia] + wa[ia+1] == "<>":
                    ri += str(ia)
                    ir += str(ia+1)
        wi = 0
        print(ri)
        print(ir)
        for ap in range(len(ri)):
            wa.pop(int(ri[ap])-wi)
            wi += 1
            wa.pop(int(ir[ap])-wi)
            wi += 1
        if wi == 0:
            break
    except Exception as e:
        iw = False
        break
if iw == True and len(wa)==0:
    print("True")
else:
    print("False")